﻿<ResourceDictionary 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  
  xmlns:local="clr-namespace:System.Controls"
  xmlns:date_time="clr-namespace:System.Controls.DateTime">

  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="Common.xaml"/>
  </ResourceDictionary.MergedDictionaries>

  <ControlTemplate x:Key="controlTemplate" TargetType="date_time:WeekDaysRadioGroup">

    <Border
      SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
      CornerRadius="{TemplateBinding CornerRadius}"
      BorderBrush="{TemplateBinding BorderBrush}"
      BorderThickness="{TemplateBinding BorderThickness}"
      Background="{TemplateBinding Background}" 
      OpacityMask="{TemplateBinding OpacityMask}">

      <WrapPanel>

        <local:RadioButton
          Foreground="{TemplateBinding Foreground}"  
          Margin="{TemplateBinding Padding}"
			    Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Culture, Converter={StaticResource c2dn}, ConverterParameter=Sunday}" 
          IsChecked="{Binding Path=Days, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource e2b}, ConverterParameter=Sunday}"/>

        <local:RadioButton
			    Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Culture, Converter={StaticResource c2dn}, ConverterParameter=Monday}" 
          IsChecked="{Binding Path=Days, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource e2b}, ConverterParameter=Monday}"
          Foreground="{TemplateBinding Foreground}" 
          Margin="{TemplateBinding Padding}"/>


        <local:RadioButton
          Foreground="{TemplateBinding Foreground}" 
          Margin="{TemplateBinding Padding}"
          Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Culture, Converter={StaticResource c2dn}, ConverterParameter=Tuesday}"
          IsChecked="{Binding Path=Days, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource e2b}, ConverterParameter=Tuesday}" />

        <local:RadioButton
			    Foreground="{TemplateBinding Foreground}" 
          Margin="{TemplateBinding Padding}"
          Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Culture, Converter={StaticResource c2dn}, ConverterParameter=Wednesday}"
          IsChecked="{Binding Path=Days, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource e2b}, ConverterParameter=Wednesday}" />

        <local:RadioButton
			    Foreground="{TemplateBinding Foreground}"
          Margin="{TemplateBinding Padding}"
          Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Culture, Converter={StaticResource c2dn}, ConverterParameter=Friday}"
          IsChecked="{Binding Path=Days, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource e2b}, ConverterParameter=Friday}"/>

        <local:RadioButton
			    Foreground="{TemplateBinding Foreground}" 
          Margin="{TemplateBinding Padding}"
          Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Culture, Converter={StaticResource c2dn}, ConverterParameter=Saturday}"
          IsChecked="{Binding Path=Days, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource e2b}, ConverterParameter=Saturday}"/>

      </WrapPanel>

    </Border>

  </ControlTemplate>


  <Style x:Key="{x:Type date_time:WeekDaysRadioGroup}" TargetType="date_time:WeekDaysRadioGroup" BasedOn="{StaticResource {x:Type Control}}">
    <Setter Property="Padding" Value="4"/>
    <Setter Property="Focusable" Value="False" />
    <Setter Property="IsTabStop" Value="False" />
    <Setter Property="Template" Value="{StaticResource controlTemplate}"/>
  </Style>


</ResourceDictionary>